package com.wiloon.java8x.dataImport;

import java.util.List;

/**
 * Created by Administrator on 2015/5/29.
 */

public class DataCellStringMultiValue extends DataCellString implements DataCellMultiValue {
    protected String[] values;

    public DataCellStringMultiValue(String value) {
        super(value);
    }

    public DataCellStringMultiValue(DataCell dataCell) {
        super();
        init(dataCell);
    }

    private void init(DataCell dataCell) {
        List<String> separators = dataCell.getColumnMap().getExcelColumn().getSeparators();
        String value = dataCell.toString();
        for (String separator : separators) {
            if (value.contains(separator)) {
                values = value.split(separator);

            }
        }
    }

    @Override
    public int getValueCount() {
        return values.length;
    }

    public String getValue(int index) {
        return values[index];
    }
}
